import numpy as np
import cv2
import json
# 根据方块对应后的像素颜色矩阵，进行地图生成预览
path = r'../.img/colorArry.txt'
file = open(path,'r')
colorArry = json.loads(file.read())


file.close()
print(len(colorArry), " ", len(colorArry[0]))
preview = np.zeros((len(colorArry),len(colorArry[0]),3), dtype=np.uint8)

for k in range(len(colorArry)):
    for i in range(len(colorArry[0])):
        preview[k][i][0] = colorArry[i][k][2]
        preview[k][i][1] = colorArry[i][k][1]
        preview[k][i][2] = colorArry[i][k][0]
cv2.imshow('preview',preview)
print('地图生成预览')
cv2.imwrite("../.img/preview.jpg", preview)
cv2.waitKey()